package Search;

import java.io.Serializable;
import java.util.List;

import user.blog.BlogIF;
import user.post.Post;

/**
 * This is a facade for class Search.
 * @author diego
 *
 */
public class SearchFacade implements Serializable {
	
	private static final long serialVersionUID = -4020823036143795912L;
	Search find;
	
	public SearchFacade(){
		find = new Search();
	}
	
	/**
	 * Search a profile by Name
	 * @param name
	 * @return a profile
	 */
	public String findProfileByName(String name){
		return find.findProfileByName(name);
	}


	/**
	 * Search a profile by Interest
	 * @param interest
	 * @return a profile
	 */
	public String findProfileByInterests(String interest){
		return find.findProfileByInterests(interest);

	}

	/**
	 * 
	 * @param gender
	 * @return
	 */
	public String findProfileByGender(String gender){
		return find.findProfileByGender(gender);

	}

	/**
	 * Find Blog by Name
	 * @param name name of blog
	 * @return the id of blog
	 */
	public String findBlogByName(String name){
		List<BlogIF>blogs = find.findBlog("TITLE",name);
		
		String impressao = "";
		
		for(int i = 0 ; i < blogs.size() ; i++ ){
			impressao += blogs.get(i).getId();
			
			if(i < blogs.size()-1)
				impressao += ",";
		}
		
		return "["+impressao+"]";
	}
	
	/**
	 * Find a blog by ID
	 * @param ID of blog
	 * @return a blog
	 */
	public BlogIF findBlogByID(String ID){
		return find.findBlogByID(ID);
	}
	

	/**
	 * Get all subblogs recursively
	 * @param ID
	 * @return
	 */
	public List<BlogIF> getAllSubBlogs(String ID){
		return find.getAllSubBlogs(ID);
	}

	/**
	 * Get a number of all sub blogs
	 * @param blogID id of blog
	 * @return number of all sub blogs
	 */
	public int getNumberAllSubBlogs(String blogID){
		return find.getNumberAllSubBlogs(blogID);
	}
	
	/**
	 * Return all blogs of system
	 * @return all blogs of system
	 */
	public List<BlogIF> getAllBlogs(){
		return find.getAllBlogs();
	}

	/**
	 * Get all posts of System
	 * @return all posts of System
	 */
	public List<Post> getAllPosts(){
		return find.getAllPosts();
	}
	
	/**
	 * Get number of comments
	 * @param login login of user
	 * @param blogIdSession Id of blog
	 * @return number of comments
	 */
	public int getNumberOfComments(String login, String blogIdSession){
		return find.getNumberOfComments(login, blogIdSession);
	}
}